/**
 * @ClassName LC1979
 * @Author ykx
 * @Date 2024/7/9 21:59
 * @Version 1.0
 */
public class LC1979 {
    public int findGCD(int[] nums) {
        int max = nums[0], min = nums[0];
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] > max) {
                max = nums[i];
            }
            if (nums[i] < min) {
                min = nums[i];
            }
        }
        return findGCD(max, min);
    }

    public int findGCD(int x, int y) {
        if (x % y == 0) {
            return y;
        } else {
            return findGCD(y, x % y);
        }
    }

}
